#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>

int main() {
    char ch[101];
    int n;
    scanf("%d", &n);
    while (scanf("%s", ch) != EOF)
    {
        size_t size = strlen(ch);
        char c[5];
        if (size >= 10)
        {
            size_t num = size - 2;
            c[0] = ch[0];
            if (num >= 10)
            {
                c[1] = num / 10 + '0';
                c[2] = num % 10 + '0';
                c[3] = ch[size - 1];
                c[4] = '\0';
            }
            else {
                c[1] = num + '0';
                c[2] = ch[size - 1];
                c[3] = '\0';
            }
            printf("%s\n", c);
        }
        else
        {
            printf("%s\n", ch);
        }
    }
    return 0;
}